import java.util.Scanner;

/**
 * Created by forcht on 2018/4/26.
 */
public class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int sum=0;
        for(int i=1;i<=n;i++){
            if(addSum(i,2)==addSum(i,10))sum++;
        }
        System.out.println(sum);
    }

    static int addSum(int n, int r) {
        int sum = 0;
        while (n > 0) {
            sum += n % r;
            n = n / r;
        }
        return sum;
    }
}
